import { Light } from "../../thirdparty/three/imports";
import { Component3D } from "../core/Component3D";

export abstract class Light3D extends Component3D
{
    _light: Light;

    get castShadow()
    {
        return this._light.castShadow;
    }
    set castShadow(v)
    {
        this._light.castShadow = v;
    }

    get color()
    {
        return this._light.color;
    }
    set color(v)
    {
        this._light.color = v;
    }

    get intensity()
    {
        return this._light.intensity;
    }
    set intensity(v)
    {
        this._light.intensity = v;
    }

    init()
    {
        super.init();
        this.entity._group.add(this._light);
        this.entity.isLight = true;
    }

    destroy(): void
    {
        this.entity._group.remove(this._light);
        this.entity.isLight = false;
        this._light = null;
        super.destroy();
    }
}
